package cn.amoqi.springboot.rabbit.rabbit.confirm;

import cn.amoqi.springboot.rabbit.rabbit.ConfirmRabbitConfig;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.UUID;

@Component
public class ConfirmSender {

    @Autowired
    RabbitTemplate rabbitTemplate;

    public void send(){
        String msgId = UUID.randomUUID().toString();
        rabbitTemplate.convertAndSend(ConfirmRabbitConfig.EXCHANGE_NAME, ConfirmRabbitConfig.ROUTE_KEY_NAME, "发送的消息", new CorrelationData(msgId));
        System.out.println("发送的消息的msgId为"+msgId);
    }
}
